class Mycanvas{
    //计时器的键
    _iv=0
    //id
    _id=''
    // 宽
    _w=0
    //高
    _h=0
    //帧率
    _frameRate=60
    //canvas上下文对象
    _ctx=null
    constructor(id,w,h) {
        this._id=id
        this._w=w
        this._h=h
        this.init()
        this.render()
    }

    init() {
        console.log('准备初始化...')
        this._ctx = document.getElementById(this._id).getContext('2d')
        this.update=this.update.bind(this)
        console.log(this._ctx)
        console.log('初始化完成')
    }

    clear() {
        this._ctx.clearRect(0,0,this._w,this._h)
    }

    update() {
        // this.clear()
        // this._ctx.beginPath()
        //绘制三角形
        this._ctx.beginPath(); //开始路径
        this._ctx.moveTo(100, 100); //三角形，左顶点
        this._ctx.lineTo(300, 100); //右顶点
        this._ctx.lineTo(300, 300); //底部的点
        this._ctx.closePath(); //结束路径
        this._ctx.stroke(); //描边路径
    }

    render() {
        console.log('核心计时器开启')
        setInterval(this.update,)
    }
}